package com.defang.application;

import com.defangit.applicant.domain.Ticket;
import com.defangit.applicant.orm.TicketService;
import laogen.lang.exception.ParameterNotValidException;

import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.util.List;

/**
 * Created by Administrator on 2019/3/13.
 */
@Path("ticket")
public class TicketResouce {
    TicketService ticketService = new TicketService();
    @GET
    @Produces("application/json")
    public Response tickets(@QueryParam("id") int id){
        return Response.ok(
                ticketService.get(id).orElseThrow(
                ()-> ParameterNotValidException.zeroIdOrEntityNonExist("当前票种")
        )).build();
    }
    @POST
    @Consumes("application/json")
    public boolean addTicket(@QueryParam("ticketTypeId") Integer ticketTypeId,Ticket ticket){
        return ticketService.addTicket(ticketTypeId,ticket)!=null;
    }
//    @POST
//    @Path("ticket={id}")
//    @Consumes("application/json")
//    public List<Ticket> applicant(@PathParam("id")Integer ticketId,List<String> openIds){
//        return ticketService.applicant(ticketId,openIds);
//    }
//    @DELETE
//    @Path("{id}")
//    public boolean delTicket(@PathParam("id") Integer ticketId){
//        return ticketService.delTicket(ticketId);
//    }


}
